//
//  BootViewController.m
//  娱
//
//  Created by dllo on 15/10/8.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "BootViewController.h"
#import "PrefixHeader.pch"
@interface BootViewController ()<UIScrollViewDelegate>
@property (nonatomic, strong) UIPageControl *pageControl;
@property (nonatomic, strong) UIScrollView *scrollView;
@end

@implementation BootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    _scrollView.contentSize = CGSizeMake(SelfViewWidth * 4, 0);
    
    _scrollView.pagingEnabled = YES;
    _scrollView.delegate = self;
    [self.view addSubview:_scrollView];
    [self.view sendSubviewToBack:_scrollView];
    
    
    self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0,SelfViewHeight - 60, SelfViewWidth, 30)];
    _pageControl.pageIndicatorTintColor = [UIColor grayColor];
    _pageControl.userInteractionEnabled = NO;
    _pageControl.currentPageIndicatorTintColor = [UIColor whiteColor];
    _pageControl.numberOfPages = 4;
    [self.view addSubview:_pageControl];
    
    
    for (NSInteger i = 1; i < 5; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(SelfViewWidth * (i - 1), 0, SelfViewWidth, SelfViewHeight)];
        NSString *str = [NSString stringWithFormat:@"引导页%ld",i];
        imageView.image = [UIImage imageNamed:str];
        [self.scrollView addSubview:imageView];
    }

    
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(SelfViewWidth / 2 - SelfViewWidth / 3 / 2 + SelfViewWidth * 3, SelfViewHeight / 4 * 3, SelfViewWidth / 3, 30);
    [button setTitle:@"点击开始" forState:UIControlStateNormal];
    button.tintColor = [UIColor whiteColor];
    button.titleLabel.font = [UIFont boldSystemFontOfSize:20];
    button.layer.borderWidth = 2;
    button.layer.borderColor = [[UIColor whiteColor] CGColor];
    button.layer.cornerRadius = 10;
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [_scrollView addSubview:button];
    
    
    UIButton *passButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    passButton.frame = CGRectMake(SelfViewWidth - 80, SelfViewHeight - 40, 60, 30);
    [passButton setTitle:@"跳过" forState:UIControlStateNormal];
    passButton.tintColor = [UIColor grayColor];
    [passButton addTarget:self action:@selector(passButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:passButton];
    
    

}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSInteger page = scrollView.contentOffset.x / SelfViewWidth;
    _pageControl.currentPage = page;
}
- (void)passButtonAction:(UIButton *)btn
{
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center postNotificationName:@"换根视图控制器" object:nil];
}
- (void)buttonAction:(UIButton *)btn
{
    
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center postNotificationName:@"换根视图控制器" object:nil];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
